{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23f6e36c-25a2-4da4-972a-9995a63f7654",
   "metadata": {},
   "outputs": [],
   "source": [
    "import openai\n",
    "\n",
    "openai.api_key = \"sk-your-key\"\n",
    "from llama_index.agent import OpenAIAgent"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4fcc9444-079d-4f35-916c-9ba1e3f12eae",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import and initialize our tool spec\n",
    "from llama_index.tools.wolfram_alpha.base import WolframAlphaToolSpec\n",
    "\n",
    "wolfram_spec = WolframAlphaToolSpec(app_id=\"your-key\")\n",
    "tools = wolfram_spec.to_tool_list()\n",
    "# Create the Agent with our tools\n",
    "agent = OpenAIAgent.from_tools(tools, verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40d3b0d7-aa2a-4729-a09c-43169d6ec107",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: wolfram_alpha_query with args: {\n",
      "  \"query\": \"100000 * 12312 * 123 + 123\"\n",
      "}\n",
      "Got output: 151437600123\n",
      "========================\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Response(response='The result of the calculation 100000 * 12312 * 123 + 123 is 151,437,600,123.', source_nodes=[], metadata=None)"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent.chat(\"what is 100000 * 12312 * 123 + 123\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5db8b3b4-dfcf-4e33-b0f7-8eef6cd26506",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: wolfram_alpha_query with args: {\n",
      "  \"query\": \"calories in 100g of milk chocolate\"\n",
      "}\n",
      "Got output: about 524 dietary Calories\n",
      "========================\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Response(response='There are approximately 524 dietary calories in 100 grams of milk chocolate.', source_nodes=[], metadata=None)"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent.chat(\"how many calories are in 100g of milk chocolate\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "251f1c81-14d6-4c54-a485-096103adda8d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Calling Function ===\n",
      "Calling function: wolfram_alpha_query with args: {\n",
      "  \"query\": \"mass of helium in the sun\"\n",
      "}\n",
      "Got output: 4.002602 unified atomic mass units\n",
      "========================\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Response(response='The mass of helium in the sun is approximately 4.002602 unified atomic mass units.', source_nodes=[], metadata=None)"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "agent.chat(\"what is the mass of the helium in the sun\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
